package com.lagou.sortdata;

import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * mapper处理三个file文件将读取到的数据排序，由于文本中每行全为数字不需要单独编辑bean类可直接使用LongWritable作为输出
 */
public class FileDataMapper extends Mapper<LongWritable, Text, LongWritable, LongWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context)
            throws IOException, InterruptedException {
        String line = value.toString();
        context.write(new LongWritable(Integer.parseInt(line)), new LongWritable(1));
    }
}
